package com.itheima.socket.sendTCP;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws IOException {
        // 请求与服务端连接
        Socket socket = new Socket("127.0.0.1", 8888);

        // 从socket 通信管道中得到一个字节输出流，用于发数据
        OutputStream os = socket.getOutputStream();

        // 把低级字节输出流包装成数据输出流
        DataOutputStream dos = new DataOutputStream(os);

        Scanner sc = new Scanner(System.in);
        while(true) {
            System.out.println("请说：");
            String s = sc.nextLine();

            dos.writeUTF(s);
            dos.flush();
        }
//        dos.close();
    }
}
